#include <stdio.h>

unsigned long gcd(unsigned long a, unsigned long b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}

int main()
{
	printf("%ld\n", gcd(4, 8));
	double left, pre=0, fra, fd, fn;
	left = 0.428571429;
	unsigned long d, n, numerator;
	for (d=1000; d<1000001; d++) {
		for (n=3*d/7+1; n>2*d/7; n--) {
			fd = d; fn = n;
			fra = fn/fd;
			if (fra < left && gcd(n, d)==1) break;				
		}
		if (fra > pre) {
			pre=fra;
			numerator = n;
		}
		if (3*d-7*n == 2)break;
	}
	printf("%ld\n", numerator);
	
}
